package cn.fscode.code.generator.model.po;

import cn.fscode.commons.mybatis.mate.annotations.FieldUnique;
import cn.fscode.commons.mybatis.mate.annotations.MyTableId;
import cn.fscode.code.generator.common.fieldbind.MyFieldBind;
import cn.fscode.code.generator.common.enums.DictTypeEnum;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;

/**
 * 字典类型表 sys_dict_type
 * 
 * @author shenguangyang
 */
@Getter
@Setter
@ToString
@TableName("sys_dict")
public class SysDictPO implements IBasePO {
    private static final long serialVersionUID = 1L;

    /** 字典主键 */
    @TableId
    @MyTableId
    private Long id;

    /** 字典名称 */
    @NotBlank(message = "字典名称不能为空")
    @Size(min = 1, max = 100, message = "字典名称长度不能超过100个字符")
    private String dictName;

    /** 字典编码 */
    @NotBlank(message = "字典编码不能为空")
    @Size(min = 1, max = 100, message = "字典编码长度不能超过100个字符")
    @FieldUnique(message = "字典已存在")
    private String dictCode;

    /** 状态（1正常 2停用） */
    @MyFieldBind(type = DictTypeEnum.DICT_STATUS, target = "statusText")
    private String status;

    /** 绑定显示属性，非表字典（排除） */
    @TableField(exist = false)
    private String statusText;

    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    /**
     * 更新时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;
}
